package com.wjf.wjfaiagent.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serial;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.Map;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.ai.chat.messages.MessageType;

/**
 * <p>
 * 聊天消息表
 * </p>
 *
 * @author wjf
 * @since 2025-09-25
 */
@Data
@Builder
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("chat_message")
public class ChatMessage implements Serializable {
   @Serial
   @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @TableField(value = "conversation_id")
    /**
     * 会话ID
     */
    private String conversationId;


    /**
     * 消息类型
     */
    @TableField("message_type")
    private MessageType messageType;

    /**
     * 消息内容
     */
    private String content;
    /**
     * 元数据
     */
    @TableField(value = "metadata", typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> metadata;
    @TableField(value = "`create_time`", fill = FieldFill.INSERT)
    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "`update_time`", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    @TableField(value = "`is_delete`")
    @TableLogic
    /**
     * 是否删除 0-未删除 1-已删除
     */
    private Boolean isDelete;

}
